Make simplify php-check-html-for-indentation and deprecate multi-modes support#742
Open
zonuexe wants to merge 5 commits into
Open
Make simplify php-check-html-for-indentation and deprecate multi-modes support#742zonuexe wants to merge 5 commits into
zonuexe wants to merge 5 commits into
Conversation
b791053 to
c30d0a3
Compare
c30d0a3 to
b420204
Compare
…s support We no longer supports mumamo, mmm-mode and multi-mode.
b420204 to
4ccdad1
Compare
Explain that php-mode targets pure PHP scripts and that files mixing HTML and PHP are handled by php-html-template-major-mode, how php-mode-maybe chooses the major mode, and the php-mode-warn-if-html-template prompt.
php-check-html-for-indentation calls php-buffer-has-html-tag on every line indentation, and the function scans the whole buffer from the start. For a plain PHP file with no HTML tag it always scans to the end, so on a large file most of the per-line indentation time is spent re-scanning. Cache the result by buffer-chars-modified-tick and recompute it only after the buffer text changes. On tcpdf.php (8513 lines, 294 KB) a warm php-cautious-indent-line drops from about 3.85 ms to 0.26 ms, and the result still tracks HTML tags added or removed by later edits.
php-check-html-for-indentation returned nil in a polymode buffer, which made php-cautious-indent-line and -region skip c-indent entirely, so PHP chunks of poly-php-html-mode were never indented. In a polymode buffer php-mode only ever indents its own PHP chunks, so return non-nil and let indentation proceed. While here: make php-warned-bad-indent buffer-local and set it consistently so a warning in one buffer does not silence others, fix the "seems to contains" prompt grammar, and give php-check-html-for-indentation a docstring describing its return value.
Add tests covering the two behaviours reworked here: PHP chunks of a PHP-in-HTML polymode must indent (a regression fix), and a PHP file that contains HTML must derive to php-html-template-major-mode. Install polymode and web-mode as development dependencies, and install dev dependencies in the test target so the tests run in CI. The poly test defines its innermode inline rather than depending on the poly-php package, because poly-php requires php-mode and would install a released copy from an archive that shadows the php-mode under test. Both tests skip when their optional package is unavailable.
fc16a36 to
fd4fe5b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We no longer supports mumamo, mmm-mode and multi-mode.